/**
 * 使用 static 修饰函数内部的变量，使其在函数调用结束后仍然保持其值
 */

#include <iostream>


void test1(int a) {
    static int x = a;
    std::cout << x << std::endl;
}

void test2(int a) {
    static int x = 0;
    x = a;
    std::cout << x << std::endl;
}

void test3() {
    static int x = 0;
    x++;
    std::cout << x << std::endl;
}

int main() {
    test1(1);
    test1(2);
    std::cout << "======" << std::endl;
    test2(1);
    test2(2);
    std::cout << "======" << std::endl;
    test3();
    test3();
    test3();
    return 0;
}